#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int t;

int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--)
	{
		int n,m,L,V;
		cin>>n>>m>>L>>V;
		int d[N],v[N],a[N];
		for(int i=1;i<=n;i++)
			cin>>d[i]>>v[i]>>a[i];
		int p[N];
		int end=0;
		for(int i=1;i<=m;i++)
		{
			cin>>p[i];
			end=max(end,p[i]);
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			if(d[i]<=end&&(v[i]>V||((V+v[i])*(V-v[i])<(end-d[i])*a[i]*2)))ans++;
		if(ans) cout<<ans<<" "<<m-1<<endl;
		else cout<<ans<<" "<<m<<endl;
	}
	return 0;
}
